package demo_IO;


import javax.swing.*;
import java.awt.*;
public class APP {
    //创建对象
    public static void main(String[] args) {
        new LoginJFrame();

    }
public static class LoginJFrame extends JFrame {
    //登入界面

    public LoginJFrame(){
        //界面宽高设置
        this.setSize(488,430);
        //界面标题
        this.setTitle("主界面");
        //界面置顶
        this.setAlwaysOnTop(true);
        //界面居中
        this.setLocationRelativeTo(null);
        //取消默认布局
        this.setLayout(null);
        //关闭虚拟机
        this.setDefaultCloseOperation(3);


        //用户名
        JLabel usernameLabel = new JLabel("用户名：");
        //输入框
        usernameLabel.setBounds(50, 50, 80, 30);
        usernameLabel.setFont(new Font("宋体", Font.PLAIN, 16));
        add(usernameLabel);

        JTextField usernameField = new JTextField();
        usernameField.setBounds(140, 50, 150, 30);
        add(usernameField);
        //密码
        JLabel passwordLabel = new JLabel("密码：");
        passwordLabel.setBounds(50, 100, 80, 30);
        passwordLabel.setFont(new Font("宋体", Font.PLAIN, 16));
        add(passwordLabel);
        //输入框
        JPasswordField passwordField = new JPasswordField();
        passwordField.setBounds(140, 100, 150, 30);
        add(passwordField);
        //功能选择
        JButton loginButton = new JButton("登录");
        loginButton.setBounds(120, 150, 80, 30);
        add(loginButton);
        JButton registerButton = new JButton("注册");
        registerButton.setBounds(240, 150, 80, 30);
        add(registerButton);
        getContentPane().setBackground(Color.LIGHT_GRAY);
        this.setVisible(true);
    }
}
}


